package com.itheima.Jiuye07;

import java.util.Scanner;

public class ExcepyionDome01 {
    public static void main(String[] args) {
        Student student = new Student();
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入学生姓名：");
        String name = sc.nextLine();
        student.setName(name);
        while (true){
            System.out.println("请输入学生年龄：");
            String i = sc.nextLine();
            try {
                int age = Integer.parseInt(i);
                student.setAge(age);
                //System.out.println(age);
                break;
            } catch (NumberFormatException e) {
                System.out.println("请输入一个整数");
                continue;
            }catch (RuntimeException e) {
             //  System.out.println(e.toString());
                System.out.println("请输入一个符合范围的年龄");
                continue;
            }
        }
        System.out.println(student.toString());
    }
}
